#pragma once

#include "../umlmodel_global.h"

#include <memory>
#include <vector>

#include "Observation.h"

using std::make_shared;
using std::shared_ptr;
using std::vector;

namespace uml {
class NamedElement;

/// <summary>
/// DurationObservation
/// A DurationObservation is a reference to a duration during an execution. It
/// points out the NamedElement(s) in the model to observe and whether the
/// observations are when this NamedElement is entered or when it is exited.
/// </summary>
class UMLMODEL_EXPORT DurationObservation : public Observation {

public: // Constructors and destructors
    explicit DurationObservation(const QString& umlType="uml::DurationObservation");

public: // JsonSerializable override
    void fromJson(const QJsonObject& json, QStringList& errorList) override;
    void toJson(QJsonObject& json) override;

public: // Properties
    /// <summary>
    /// events getter
    /// The DurationObservation is determined as the duration between the entering or
    /// exiting of a single event Element during execution, or the entering/exiting of
    /// one event Element and the entering/exiting of a second.
    /// </summary>
    vector<shared_ptr<NamedElement>>& events();

    /// <summary>
    /// firstEvents getter
    /// The value of firstEvent[i] is related to event[i] (where i is 1 or 2). If
    /// firstEvent[i] is true, then the corresponding observation event is the first
    /// time instant the execution enters event[i]. If firstEvent[i] is false, then the
    /// corresponding observation event is the time instant the execution exits
    /// event[i].
    /// </summary>
    vector<bool>& firstEvents();

private: // Fields
    /// <summary>
    /// events
    /// The DurationObservation is determined as the duration between the entering or
    /// exiting of a single event Element during execution, or the entering/exiting of
    /// one event Element and the entering/exiting of a second.
    /// </summary>
    vector<shared_ptr<NamedElement>> events_;

    /// <summary>
    /// firstEvents
    /// The value of firstEvent[i] is related to event[i] (where i is 1 or 2). If
    /// firstEvent[i] is true, then the corresponding observation event is the first
    /// time instant the execution enters event[i]. If firstEvent[i] is false, then the
    /// corresponding observation event is the time instant the execution exits
    /// event[i].
    /// </summary>
    vector<bool> firstEvents_;

};

} // namespace uml
